from Numbers import rep_unit_len
from Primes import is_prime
import itertools

print sum(itertools.islice(
        itertools.ifilter(
            lambda x: not is_prime(x) and \
                x % 2 != 0 and \
                x % 5 != 0 and \
                (x - 1) % rep_unit_len(x) == 0,
            itertools.count(6)), 25))


